package cn.kimoon.dau_android;

import android.annotation.SuppressLint;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import java.util.LinkedList;

import cn.kimoon.dau_android.Model.ModelCollectorInfo;
import cn.kimoon.dau_android.Model.ModelContactItem;

/**
 * Created by xiangdong on 2016/11/23.
 */

public class ControlFragment extends Fragment implements AdapterView.OnItemClickListener {
    private ModelCollectorInfo info;
    private ControlAdapter adapter;

    public void setInfo(ModelCollectorInfo info) {
        this.info = info;

        if (adapter != null) {
            adapter.setInfo(info);
        }
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_control, container, false);
        initSubViews(view);
        return view;
    }

    private void initSubViews(View view) {
        ListView listView = (ListView) view.findViewById(R.id.control_list_view);
        adapter = new ControlAdapter(info, getActivity());
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(this);
    }

    // 按键点击
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        System.out.println("点击时间的view ID = " + view.getId() + " position = " + position);
    }
}
